﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class export_onlineExamExport : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //只显示学生选了课的考试
        string test_question_id = "";
        string test_question_name = "";
        //Session["student_id"] = "3120182109222";
        System.Data.DataTable table1 = new System.Data.DataTable();
        int count = 0;//总记录的条数

        try
        {
           
            if (Request.QueryString["test_question_id"] != null)
            {
                test_question_id = Request.QueryString["test_question_id"].ToString().Trim();
            }
            if (Request.QueryString["test_question_name"] != null)
            {
                test_question_name = Request.QueryString["test_question_name"].ToString().Trim();
            }

           
            List<string> wheres = new List<string>();

            if (test_question_id != "")
            {
                wheres.Add("test_question_id like '%" + test_question_id + "%'");
            }
            if (test_question_name != "")
            {
                wheres.Add("test_question_name like '%" + test_question_name + "%'");
            }
            string wh = "";
            if (wheres.Count > 0)
            {
                wh = string.Join(" and ", wheres.ToArray());
                
            }
            
            string sql = "select test_question_id,test_question_name,course_id,radio_questions_sum,mutil_questions_sum,"
                        + "judge_questions_sum,answer_questions_sum from tb_test_questions where course_id in   "
                + "(select course_id from tb_score where student_id = '" + Session["student_id"] + "')";
            if (wheres.Count > 0)
            {
                sql = sql + " and  " + wh ;

            }
            
            table1 = SqlServer.GetDataTable(sql);
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('有错误')</script>");
            Response.End();
        }
        Response.Write(Json.ToJson(table1, count));
        Response.End();

    }


}